from pydantic import BaseModel
from typing import List, Any, Union


class SuiteCondition(BaseModel):
	method: int
	value: Any
	andOr: str


class ApiHeadersModel(BaseModel):
	key: str
	value: str


class CheckModel(BaseModel):
	method: str
	exp: Any
	act: Any
	type: str


class RunModel(BaseModel):
	method: str
	exp: Any
	act: Any
	type: str
	andOr: str


class LoopModel(BaseModel):
	exp: Any
	type: str


class ApiExtractModel(BaseModel):
	key: str
	value: str


class FuncExtractModel(BaseModel):
	key: str


class ParamsModel(BaseModel):
	value: Any
	type: str


class StepModel(BaseModel):
	desc: str  # 步骤描述
	key: list  # 步骤类型和对应的key
	api_headers: Union[List[ApiHeadersModel], List]  # 接口请求头
	api_body: str  # 接口请求体
	step_after: bool  # 退出while循环的条件判断是在执行步骤前还是执行步骤后
	body_type: str  # 接口请求类型
	body_type: str  # 接口请求类型
	api_params: list  # 接口查询参数
	extract: Union[List[ApiExtractModel], List[FuncExtractModel], List]   # 步骤数据提取
	check: Union[List[CheckModel], List]   # 步骤断言
	params: Union[List[ParamsModel], List]   # 函数入参
	run: Union[List[RunModel], List]  # 是否执行该步骤
	loop: Union[List[LoopModel], List]  # 循环执行该步骤
	until: Union[List[RunModel], List]  # while条件判断语句



